<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    数字1: <input type="text" id="num1"><br>
    数字2: <input type="text" id="num2"><br>
    <button onclick="ope(1)"> + </button>
    <button onclick="ope(2)"> - </button>
    <button onclick="ope(3)"> &times; </button>
    <button onclick="ope(4)"> &divide; </button>
    结果:<span id="result"></span>
    <script>
        function ope(n){
            var n1 = Number(document.getElementById('num1').value);
            var n2 = Number(document.getElementById('num2').value);
            console.log(n1, n2);
            var res = null;
            switch(n){
                case 1: res = n1 + n2; break;
                case 2: res = n1 - n2; break;
                case 3: res = n1 * n2; break;
                case 4: res = n1 / n2; break;
            }
            var result = document.getElementById('result');
            result.innerHTML = res;
        }
    </script>
</body>
</html>